package com.dongge.util;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created by Administrator on 2015/11/12.
 */
public class ApplicationListener implements ServletContextListener {
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext application = sce.getServletContext();
        ApplicationContext applicationContext = (ApplicationContext)application.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        System.out.println(applicationContext);
    }

    public void contextDestroyed(ServletContextEvent sce) {

    }
}
